package cn.iocoder.yudao.module.system.controller.admin.investment;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.InvestmentReqVO;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.ParticipationReqVO;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.ParticipationRespVO;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.ParticipationUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.investment.SystemParticipation;
import cn.iocoder.yudao.module.system.dal.dataobject.merchant.MerchantDO;
import cn.iocoder.yudao.module.system.service.investment.ParticipationService;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author 梁富贵
 * @Date 2024/10/11
 **/
@RestController
@Tag(name = "管理后台 - 参与招商者")
@RequestMapping("/system/participation")
@Validated
public class ParticipationController {
    @Resource
    private ParticipationService participationService;

    @Schema(description = "删除参与招商者")
    @DeleteMapping("/delete")
    public int deleteParticipation(@RequestParam("id") Integer id) {
        return participationService.deleteParticipation(id);
    }

    @Schema(description = "更新参与招商者")
    @PutMapping("/update")
    public CommonResult<Integer> updateParticipation(@ModelAttribute ParticipationUpdateReqVO participationUpdateReqVO) throws IOException {



        return CommonResult.success(participationService.updateParticipation(participationUpdateReqVO,"/system/participation"));
    }

    @Schema(description = "管理员获取参与招商者分页")
    @PostMapping("/page")
    public CommonResult<PageResult<ParticipationRespVO>> getParticipationPage(@RequestBody ParticipationReqVO reqVO) {
        return CommonResult.success(participationService.getParticipationPage(reqVO));
    }

    @Schema(description = "商家获取获取参与招商者列表")
    @GetMapping("/list")
    public CommonResult<PageResult<ParticipationRespVO>> getParticipationList(@Valid ParticipationReqVO reqVO) {
        return CommonResult.success(participationService.getParticipationListByUserId(reqVO));
    }

    @Schema(description = "通过参与招商的申请")
    @PostMapping("/passed")
    public CommonResult<Integer> passedParticipation(@RequestBody List<Integer> ids) {
        return CommonResult.success(participationService.passingParticipationList(ids));
    }

    @Schema(description = "驳回参与招商的申请")
    @PostMapping("/reject")
    public CommonResult<Integer> rejectParticipation(@RequestBody List<Integer> ids) {
        return CommonResult.success(participationService.rejectParticipationApplications(ids));
    }

}
